<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>org.openmrs.logic</title>
</head>
<body>

<p>The OpenMRS Logic Service provides access to granular and derived
data. Medical data is extremely complex. While a dictionary-based system
provides tremendous flexibility in collecting data, consuming the data
for decision support, reporting, research question, or even for display
within the web application can be increasingly difficult. For example,
even answering a simple question like "is the patient HIV positive?" may
require a complex algorithm that considers the results of multiple lab
results, temporal relations of results, orders, and questionnaire
responses. Ideally, this "business logic" is defined in one place and
easily accessible to all aspects of the system &mdash; e.g., whether we're
displaying HIV status on a web page, generating a PEPFAR report, or
executing a decision support alert, the same algorithm should be used.
We call this bit of business knowledge a "rule." Rules should be
easily accessible and return predictable and flexible results.</p>

<p>Rules can be fashioned from just about any source, but must
compile into a Java class that extends org.openmrs.logic.Rule (@see org.openmrs.logic.Rule).</p>

<p>Data can be obtained from the logic service like this:</p>

<code>
  Patient myPatient = Context.getPatientService().getPatient(123);
  LogicService ls = Context.getLogicService();
  Result age = ls.eval(myPatient, "AGE");
</code>

</body>
</html>